package com.starview.platform.resource.catalog;

import com.starview.platform.data.value.ResourceURI;
import com.starview.platform.resource.ResourceException;
import com.starview.star.compiler.util.PrettyPrintable;

public interface Catalog extends PrettyPrintable
{
  public static final String CATALOG = "catalog"; // Standard name for a catalog

  /**
   * The name of this catalog
   * 
   * @return
   */
  String getName();

  /**
   * Look for a particular named entity.
   * 
   * @param name
   * @return the uri corresponding to the entity
   * @throws CatalogException
   *           if the named entity is not present
   */
  ResourceURI resolve(String name) throws CatalogException;
  
  /**
   * Look for a particular named entity, but do not use the fallback catalog even if one is given.
   * 
   * @param name
   * @return the uri corresponding to the entity or null if it is not in the catalog
   * @throws ResourceException
   */
  ResourceURI resolveNoFallback(String name) throws ResourceException;
  /**
   * Resolve a relative uri based on the catalog's idea of where everything is
   */
  ResourceURI resolve(ResourceURI uri) throws ResourceException;
  
  /**
   * If the catalog permits, add a new entry to the catalog
   * 
   * @param name
   * @param uri
   * @throws CatalogException
   *           if additions are not permitted
   */
  void addEntry(String name, ResourceURI uri) throws CatalogException;
}
